package com.eastfair.venuebooking.controller;


import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.common.dto.AttachmentFileDTO;
import com.eastfair.common.dto.AttachmentFilePageQuery;
import com.eastfair.common.dto.AttachmentFileSaveDTO;
import com.eastfair.common.vo.AttachmentFileVO;
import com.eastfair.core.base.R;
import com.eastfair.venuebooking.dto.SpaceSaveDTO;
import com.eastfair.venuebooking.service.DrawingService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 场地表
 * </p>
 *
 * @author lyw
 * @date 2022-07-04
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/drawing")
public class DrawingController {
    @Autowired
    private DrawingService drawingService;

    /**
     * 图纸列表
     *
     * @return
     */
    @ApiOperation(value = "图纸列表")
    @PostMapping(value = "/getDrawingList")
    public R<List<AttachmentFileVO>> getDrawingList(@RequestBody AttachmentFileDTO attachmentFileDTO) {
        List<AttachmentFileVO> drawingList = drawingService.getDrawingList(attachmentFileDTO);

        return R.success(drawingList);
    }


    /**
     * 添加图纸
     *
     * @return
     */
    @SysLog("添加图纸")
    @ApiOperation(value = "添加图纸")
    @PostMapping(value = "/saveDrawingInfo")
    public R<Boolean> saveDrawingInfo(@RequestBody List<AttachmentFileSaveDTO> attachmentFileSaveDTOList) {

        return R.success(drawingService.saveDrawingInfo(attachmentFileSaveDTOList));
    }

    /**
     * 删除图纸
     *
     * @return
     */
    @SysLog("删除图纸")
    @ApiOperation(value = "删除图纸")
    @PostMapping(value = "/delDrawingById")
    public R<Boolean> delDrawingById(@RequestBody List<Long> ids) {

        return R.success(drawingService.delDrawingById(ids));
    }


}
